package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IEngineeringInstallStatusFormanagerView;
import com.cloudsigns.factorymanager2.engineering.bean.EngineeringInstallStatuBean;
import com.cloudsigns.factorymanager2.engineering.model.EngineeringInstallStatusFormanagerModel;
import com.cloudsigns.factorymanager2.engineering.model.IEngineeringInstallStatusFormanagerModel;

import java.util.List;

/**
 * Created by tony on 2018/6/16.
 */

public class EngineeringInstallStatusFormanagerPresenter {
    private IEngineeringInstallStatusFormanagerView view;
    private IEngineeringInstallStatusFormanagerModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public EngineeringInstallStatusFormanagerPresenter(IEngineeringInstallStatusFormanagerView view) {
        this.view = view;
        this.model = new EngineeringInstallStatusFormanagerModel();
    }

    public void engineeringInstallStatusFormanager() {


        model.engineeringInstallStatusFormanager(new EngineeringInstallStatusFormanagerModel.OnEngineeringInstallStatusFormanagerListener() {
            @Override
            public void engineeringInstallStatusFormanagerSuccessed(final List<EngineeringInstallStatuBean> engineeringInstallStatuBeanList) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getEngineeringInstallStatusSuccessed(engineeringInstallStatuBeanList);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void engineeringInstallStatusFormanagerFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getEngineeringInstallStatusFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
